package com.woniuxy.oldmanapi.controller;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.woniuxy.oldmanapi.entity.Building;
import com.woniuxy.oldmanapi.entity.Storey;
import com.woniuxy.oldmanapi.service.BuildingService;
import com.woniuxy.oldmanapi.vo.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class BuildController {

    @Autowired
    BuildingService buildingService;

    @GetMapping("/building/selectAllList")
    public ResponseResult<List<Building>> selectAllList() {
        ResponseResult<List<Building>> result = new ResponseResult<>();
        try {
            List<Building> list = buildingService.selectAllList();
            if (list != null) {
                result.setCode(200);
                result.setData(list);
                result.setMsg("查询成功");
            }
        } catch (Exception e) {
            e.printStackTrace();
            result.setMsg("系统繁忙,请稍后再试");
            result.setCode(205);
        }
        return result;
    }
}

